#!/usr/bin/env python
#coding=utf-8

from numpy import array
import json 



radius = 3000
points = [
    array((139382.3437,146047.0951)),
    array((157688.4185,148489.0310)),
    array((149441.1622,167278.6394)),
    array((131764.7130,162103.0925)) 
]
with open("points.txt") as f:
    for line in f:
        x, y = line.split(',')
        points.append(array((float(x), float(y))))

# 点到点的流量
with open("graph.txt") as f:
    edges = array(json.loads(f.read()), dtype=float)
# edges *= (1.05**30)


areas = [0,0,0,0, 1.0999, 1.72968, 2.08295, 1.40976, 1.05233, 1.5041, 1.45598, 2.21977, 2.21551, 0.698477, 1.24976, 1.02762, 1.8403, 2.07282, 2.22723, 0.76776, 1.15631, 3.32411, 1.01302, 0.551639, 0.594429, 2.91143, 3.81063, 1.0311, 0.93738, 0.80786, 0.481672, 0.516613, 0.730858, 0.599673, 1.4383, 4.22407, 1.41888, 1.56458, 3.73639, 3.97479, 1.88011, 1.8154, 3.09574, 2.96373, 0.857261, 0.701876, 2.15647, 3.29661, 3.68917, 1.08202, 2.33987, 2.28435, 1.54207, 5.03772, 0.831737, 1.84288, 2.09311, 0.756723, 0.377109, 0.317139, 1.20173, 0.585205, 0.58307, 0.540932, 0.251213, 1.96525, 0.871552, 6.03257, 2.08167, 1.48257, 2.72525, 3.41281, 3.89381, 2.04518, 0.928985, 0.991851, 2.34944, 0.676652, 3.82263, 2.94285, 2.55062, 7.33121, 3.91183, 1.25663, 1.13472, 0.920252, 0.984825, 1.19439, 1.1332, 0.611854, 0.87682, 0.429337, 3.13677, 4.412, 1.4624, 0.758176, 2.63654, 4.54422, 0.847727, 2.95428, 1.038, 0.247467, 0.269078, 8.70943, 3.03517, 3.4433, 7.17516, 10.4593, 12.4925, 24.2219, 10.5661, 7.22554, 11.9462, 12.0177]

def getPointThroughput(x):
    assert type(x) is int
    return edges[x].sum() + edges.transpose()[x].sum()

def distance(a, b):
    """
    两个二维平面点之间的欧几里得距离
    """
    x = array(a)
    y = array(b)
    assert x.shape == (2,)
    assert y.shape == (2,)

    return np.linalg.norm(x-y)